package com.codingman.springbootdemo8;

import static org.junit.jupiter.api.Assertions.*;

import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

@SpringBootTest
class EmployeeRepositoryTest1 {

	@Autowired
	private EmployeeRepository repo;

	@Test
	void test() {
		assertTrue(repo != null);
		
		Employee e = new Employee();
		e.setName("ggg");
		e.setPassword("789");
		e.setEmail("ggg@codingman.com");
		e.setSex("F");
		e.setCountry("China");
		
//		repo.save(e);
		
//		e.setId(1);
//		e.setName("fff");
//		assertTrue(repo.save(e) != null);
		
//		assertTrue(repo.delete(1));
		
//		e = repo.findById(4).get();
//		System.out.println(e);
		
//		e = repo.findById(100).orElse(new Employee());
//		e = repo.findById(100).orElseThrow(() -> new RuntimeException("空容器异常"));
		
		e = repo.findByName("ccc").get();
		System.out.println(e);
				
		for(Employee employee: repo.findAll())
		{
			System.out.println(employee);
		}
	}

}
